package com.share.rules.api;

import com.share.common.core.domain.R;
import com.share.rules.api.domain.FeeRule;
import com.share.rules.api.domain.FeeRuleRequestForm;
import com.share.rules.api.domain.FeeRuleResponseVo;
import com.share.rules.service.IFeeRuleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @return 13141
 * 2025/10/15
 * 8:34
 */
@Slf4j
@Tag(name = "费用规则API管理")
@RestController
@RequestMapping("/feeRule")
@SuppressWarnings({"unchecked", "rawtypes"})
public class FeeRuleApiController {

    @Autowired
    private IFeeRuleService feeRuleService;


    // 计算订单费用
    @Operation(summary = "计算订单费用")
    // @InnerAuth
    @PostMapping("/calculateOrderFee")
    public R<FeeRuleResponseVo> calculateOrderFee(@RequestBody FeeRuleRequestForm calculateOrderFeeForm) {
        FeeRuleResponseVo feeRuleResponseVo = feeRuleService.calculateOrderFee(calculateOrderFeeForm);
        return R.ok(feeRuleResponseVo);
    }

    @Operation(summary = "批量获取费用规则信息")
    // @InnerAuth
    @PostMapping(value = "/getFeeRuleList")
    public R<List<FeeRule>> getFeeRuleList(@RequestBody List<Long> feeRuleIdList)
    {
        List<FeeRule> feeRuleList = feeRuleService.listByIds(feeRuleIdList);
        return R.ok(feeRuleList);
    }

    @Operation(summary = "获取费用规则详细信息")
    // @InnerAuth
    @GetMapping(value = "/getFeeRule/{id}")
    public R<FeeRule> getFeeRule(@PathVariable("id") Long id)
    {
        FeeRule feeRule = feeRuleService.getById(id);
        return R.ok(feeRule);
    }

}
